package com.yutel.multher;

import java.util.Properties;

import com.yutel.multher.reaper.ReaperServer;
import com.yutel.multher.reaper.domain.ServerType;
import com.yutel.multher.reaper.domain.TaskData;

public class ReaperFactory<T extends TaskData> {

	public ReaperServer<T> createReaperServer(Properties props) {
		ReaperServer<T> reaperServer = new ReaperServer<T>();
		String serverType = props.getProperty("reaper.type");
		if ("1".equals(serverType)) {
			reaperServer.setServerType(ServerType.QUEUE);
		} else {
			reaperServer.setServerType(ServerType.AUTARKIC);
		}
		String queueMin = props.getProperty("queue.data.min");
		reaperServer.setQueueMin(Integer.parseInt(queueMin));
		String queueMax = props.getProperty("queue.data.max");
		reaperServer.setQueueMax(Integer.parseInt(queueMax));
		String queueInterval = props.getProperty("queue.load.interval");
		reaperServer.setQueueInterval(Integer.parseInt(queueInterval));
		String taskCount = props.getProperty("task.thread.count");
		reaperServer.setTaskCount(Integer.parseInt(taskCount));
		String taskInterval = props.getProperty("task.thread.interval");
		reaperServer.setTaskInterval(Integer.parseInt(taskInterval));
		return reaperServer;
	}
}
